/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.inventory.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author sithum
 */
@Entity
@Table(name = "ROUTE", catalog = "", schema = "APP")
@NamedQueries({@NamedQuery(name = "Route.findAll", query = "SELECT r FROM Route r"), @NamedQuery(name = "Route.findByRouteId", query = "SELECT r FROM Route r WHERE r.routeId = :routeId"), @NamedQuery(name = "Route.findByRouteName", query = "SELECT r FROM Route r WHERE r.routeName = :routeName"),
    @NamedQuery(name = "Route.recordCount", query = "SELECT COUNT(r) FROM Route r")})
public class Route implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ROUTE_ID", nullable = false)
    private Integer routeId;
    @Basic(optional = false)
    @Column(name = "ROUTE_NAME", nullable = false, length = 45)
    private String routeName;
    @OneToMany(mappedBy = "routeId", cascade={CascadeType.PERSIST, CascadeType.MERGE})
    private List<CustomerDetails> customerDetailsCollection;

    public Route() {
    }

    public Route(Integer routeId) {
        this.routeId = routeId;
    }

    public Route(Integer routeId, String routeName) {
        this.routeId = routeId;
        this.routeName = routeName;
    }

    public Integer getRouteId() {
        return routeId;
    }

    public void setRouteId(Integer routeId) {
        this.routeId = routeId;
    }

    public String getRouteName() {
        return routeName;
    }

    public void setRouteName(String routeName) {
        this.routeName = routeName;
    }

    public List<CustomerDetails> getCustomerDetailsCollection() {
        return customerDetailsCollection;
    }

    public void setCustomerDetailsCollection(List<CustomerDetails> customerDetailsCollection) {
        this.customerDetailsCollection = customerDetailsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (routeId != null ? routeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Route)) {
            return false;
        }
        Route other = (Route) object;
        if ((this.routeId == null && other.routeId != null) || (this.routeId != null && !this.routeId.equals(other.routeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.inventory.entities.Route[routeId=" + routeId + "]";
    }
}
